package com.himore.api.web.controller.modules;

import java.util.List;

import com.himore.api.common.annotation.Log;
import com.himore.api.common.core.controller.BaseController;
import com.himore.api.common.core.domain.AjaxResult;
import com.himore.api.common.core.page.TableDataInfo;
import com.himore.api.common.enums.BusinessType;
import com.himore.api.common.utils.poi.ExcelUtil;
import com.himore.api.web.model.TSignAwards;
import com.himore.api.web.service.ITSignAwardsService;
import io.swagger.annotations.Api;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 签单奖品信息Controller
 * 
 * @author ruoyi
 * @date 2021-01-21
 */
@Api(tags = "签到奖品管理")
@RestController
@RequestMapping("/system/signAwards")
public class TSignAwardsController extends BaseController
{
    @Autowired
    private ITSignAwardsService tSignAwardsService;

    /**
     * 查询签单奖品信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TSignAwards tSignAwards)
    {
        startPage();
        List<TSignAwards> list = tSignAwardsService.selectTSignAwardsList(tSignAwards);
        return getDataTable(list);
    }

    /**
     * 导出签单奖品信息列表
     */
    @Log(title = "签单奖品信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TSignAwards tSignAwards)
    {
        List<TSignAwards> list = tSignAwardsService.selectTSignAwardsList(tSignAwards);
        ExcelUtil<TSignAwards> util = new ExcelUtil<TSignAwards>(TSignAwards.class);
        return util.exportExcel(list, "awards");
    }

    /**
     * 获取签单奖品信息详细信息
     */
    @GetMapping(value = "/{awardId}")
    public AjaxResult getInfo(@PathVariable("awardId") Long awardId)
    {
        return AjaxResult.success(tSignAwardsService.selectTSignAwardsById(awardId));
    }

    /**
     * 新增签单奖品信息
     */
    @Log(title = "签单奖品信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TSignAwards tSignAwards)
    {
        return toAjax(tSignAwardsService.insertTSignAwards(tSignAwards));
    }

    /**
     * 修改签单奖品信息
     */
    @Log(title = "签单奖品信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TSignAwards tSignAwards)
    {
        return toAjax(tSignAwardsService.updateTSignAwards(tSignAwards));
    }

    /**
     * 删除签单奖品信息
     */
    @Log(title = "签单奖品信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{awardIds}")
    public AjaxResult remove(@PathVariable Long[] awardIds)
    {
        return toAjax(tSignAwardsService.deleteTSignAwardsByIds(awardIds));
    }
}
